package cn.kimming.wms.query;

import java.math.BigDecimal;

import org.apache.commons.lang3.StringUtils;

import lombok.Getter;
import lombok.Setter;

public class ProductStockQueryObject extends QueryObject {
	@Getter
	@Setter
	private String keyword; // 货品名称或编码关键字
	@Getter
	@Setter
	private Long depotId = -1L; // 所在仓库
	@Getter
	@Setter
	private Long brandId = -1L; // 所属品牌
	@Getter
	@Setter
	private BigDecimal stockLimit; // 库存量阈值:小于等于阈值

	@Override
	protected void customizedQuery() {
		if (StringUtils.isNoneEmpty(keyword)) {
			addCondition("(obj.product.name like ? or obj.product.sn like ?)", "%" + keyword + "%",
					"%" + keyword + "%");
		}
		if (depotId > 0) {
			addCondition("obj.depot.id = ?", depotId);
		}
		if (brandId > 0) {
			addCondition("obj.product.brand.id = ?", brandId);
		}
		if (stockLimit != null) {
			addCondition("obj.stockNumber <= ?", stockLimit);
		}
		addCondition("obj.stockNumber > ?", BigDecimal.ZERO);
	}
}
